﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace CSEPT.Controllers
{
    public class RegisterController : Controller
    {
        
        [LoggedIn]
        public ActionResult Register(int EventID){
            Models.RegisterViewModel RVM = new Models.RegisterViewModel();
            RVM.bib = RVM.dal.GetBib(RVM.CurrUser.ID, EventID);
            return View(RVM);
        }
        [LoggedIn]
        public ActionResult Update(Bib bib){
            Models.RegisterViewModel RVM = new Models.RegisterViewModel();
            RVM.dal.UpdateBib(bib);
            return RedirectToAction("IndexInfo", "Index", new {@Message = "Succesfully updated registration", @Type = "success"});
        }
        [LoggedIn]
        public ActionResult Delete(int ID){

            Models.RegisterViewModel RVM = new Models.RegisterViewModel();
            RVM.dal.DeleteBib(ID);
            return RedirectToAction("IndexInfo", "Index", new {@Message = "Succesfully unregistered from the event.", @Type = "warning"});
        }
    }
}

